package com.ty.springbootshiro.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ty.springbootshiro.entity.Right;
import com.ty.springbootshiro.entity.Role;
import com.ty.springbootshiro.entity.User;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * RoleMapper
 *
 * @author whs
 * @since 2024/9/21
 */
public interface RoleMapper extends BaseMapper<Role> {

    Page<Role> rolePage(@Param("roleName") String roleName, Page<Role> rolePager);

    List<Role> list();
//    //角色增删改查
//    public List<Role> findAllRoles();
//    //权限查询
//    public List<Right> findAllRights();
//    public List<Right> findRightsByRole(Role role);
//

    Role saveRole(Role role);
    void deleteRole(@Param("roleId") Long roleId); // 删除
    Role getRole(@Param("roleId") Long roleId); // 按主键查询单条

    List<Right> findRightsByRole(Role role); // 根据角色查询权限
    List<Right> findAllRights(); // 查询所有

    // 根据用户查询角色对象
    Role findRoleByUsers(User user);


}
